// 用户选择场次api
import request from '../axios'
var qs = require('qs')

// 获取list
const optionList = data => {
  return request({
    url: `/custom/owens/sessions`,
    method: 'get',
    params: data
  })
}

// 提交选择场次id
/**
 * 需要token
 * @param {Content-Type} Headers application/x-www-form-urlencoded
 */
const submitOptionId = (data, session) => {
  return request({
    url: `/custom/owens/sessions/${session}`,
    method: 'post',
    data: qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
// 修改作品视频
/**
 * @param {media_url} data 视频播放地址
 * @param {file_id} data 视频文件唯一标识
 */
const changeVideo = (data) => {
  return request({
    url: `/custom/owens/change/video`,
    method: 'post',
    data: qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
const getSignature = () => {
  var data = { Action: 'GetUgcUploadSign' }
  return request({
    url: `/custom/owens/video/signature`,
    method: 'post',
    data: qs.stringify(data)
  })
}
// 分享
/**
 * @param {target_url} data 当前分享页面的URL,若有参数记得url encode
 */
const share = (data) => {
  return request({
    url: `/jssdk`,
    method: 'get',
    params: data
  })
}

export default { optionList, submitOptionId, changeVideo, getSignature, share }
